package com.aurora.source.widget;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.aurora.source.R;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author vondear
 * @date 2016/7/19
 * Mainly used for confirmation and cancel.
 */
public class RecordDialogEditSureCancel extends RxDialog {


    @BindView(R.id.tv_cancel)
    TextView tvCancel;
    @BindView(R.id.tv_affirm)
    TextView tvAffirm;

    public RecordDialogEditSureCancel(Context context, int themeResId) {
        super(context, themeResId);
        initView();
    }

    public void setOnSureClick(View.OnClickListener onSureClick){
        tvAffirm.setOnClickListener(onSureClick);
    }

    public RecordDialogEditSureCancel(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        initView();
    }

    public RecordDialogEditSureCancel(Context context) {
        super(context);
        initView();
    }

    public TextView getSureView() {
        return tvAffirm;
    }

    public void setSure(String strSure) {
        this.tvAffirm.setText(strSure);
    }

    public TextView getCancelView() {
        return tvCancel;
    }

    public void setCancel(String strCancel) {
        this.tvCancel.setText(strCancel);
    }


    public RecordDialogEditSureCancel(Activity context) {
        super(context);
        initView();
    }

    public RecordDialogEditSureCancel(Context context, float alpha, int gravity) {
        super(context, alpha, gravity);
        initView();
    }

    private void initView() {
        View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.item_record_details, null);
        ButterKnife.bind(this, dialogView);
        setContentView(dialogView);
        tvCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(isShowing()){
                    dismiss();
                }
            }
        });
    }
}
